package com.lpit.controller;

import com.lpit.constant.Constant;
import com.lpit.result.ResponseResult;
import com.lpit.service.impl.ReplyServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/auto")
public class ReplyController {
    @Autowired
    ReplyServiceImpl replyService;
    /**
     * 设置关键词自动回复
     */
    @GetMapping("/{message}")
    public ResponseResult<String> handleUserMessage(@PathVariable String keyword){
        String autoMessage = replyService.getAutoMessage(keyword);
        if(autoMessage != null){
            return new ResponseResult(200,autoMessage);
        } else {
            return new ResponseResult(400, Constant.NO_FOUND_MESSAGE);
        }

    }
}
